package huu.phong.googlemusic.model;

import huu.phong.googlemusic.MusicManager;
import huu.phong.googlemusic.Utils;

import java.io.File;
import java.io.IOException;
import java.io.Serializable;
import java.net.URISyntaxException;


public class Song implements Serializable {
	private static final long serialVersionUID = 4181241940156276544L;

	private String genre;
	private int beatsPerMinute;
	private String albumArtistNorm;
	private String artistNorm;
	private String album;
	private long lastPlayed;
	private String artistImageBaseUrl;
	private int type;
	private long recentTimestamp;
	private int disc;
	private String id;
	private String composer;
	private String title;
	private String albumArtist;
	private String artistMatchedId;
	private String totalTracks;
	private boolean subjectToCuration;
	private String name;
	private int totalDiscs;
	private int year;
	private String titleNorm;
	private String artist;
	private String albumNorm;
	private int track;
	//private String origin;
	private long durationMillis;
	private String matchedId;
	private String albumArtUrl;
	private boolean deleted;
	private String url;
	private String albumMatchedId;
	private long creationDate;
	private long playCount;
	private int bitrate;
	private int rating;
	private String comment;
	private String storeId;

	public Song() {
		
	}

	public String getGenre() {
		return genre;
	}

	public void setGenre(String genre) {
		this.genre = genre;
	}

	public int getBeatsPerMinute() {
		return beatsPerMinute;
	}

	public void setBeatsPerMinute(int beatsPerMinute) {
		this.beatsPerMinute = beatsPerMinute;
	}

	public String getAlbumArtistNorm() {
		return albumArtistNorm;
	}

	public void setAlbumArtistNorm(String albumArtistNorm) {
		this.albumArtistNorm = albumArtistNorm;
	}

	public String getArtistNorm() {
		return artistNorm;
	}

	public void setArtistNorm(String artistNorm) {
		this.artistNorm = artistNorm;
	}

	public String getAlbum() {
		return album;
	}

	public void setAlbum(String album) {
		this.album = album;
	}

	public long getLastPlayed() {
		return lastPlayed;
	}

	public void setLastPlayed(long lastPlayed) {
		this.lastPlayed = lastPlayed;
	}

	public String getArtistImageBaseUrl() {
		return artistImageBaseUrl;
	}

	public void setArtistImageBaseUrl(String artistImageBaseUrl) {
		this.artistImageBaseUrl = artistImageBaseUrl;
	}

	public int getType() {
		return type;
	}

	public void setType(int type) {
		this.type = type;
	}

	public long getRecentTimestamp() {
		return recentTimestamp;
	}

	public void setRecentTimestamp(long recentTimestamp) {
		this.recentTimestamp = recentTimestamp;
	}

	public int getDisc() {
		return disc;
	}

	public void setDisc(int disc) {
		this.disc = disc;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getComposer() {
		return composer;
	}

	public void setComposer(String composer) {
		this.composer = composer;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getAlbumArtist() {
		return albumArtist;
	}

	public void setAlbumArtist(String albumArtist) {
		this.albumArtist = albumArtist;
	}

	public String getArtistMatchedId() {
		return artistMatchedId;
	}

	public void setArtistMatchedId(String artistMatchedId) {
		this.artistMatchedId = artistMatchedId;
	}

	public String getTotalTracks() {
		return totalTracks;
	}

	public void setTotalTracks(String totalTracks) {
		this.totalTracks = totalTracks;
	}

	public boolean isSubjectToCuration() {
		return subjectToCuration;
	}

	public void setSubjectToCuration(boolean subjectToCuration) {
		this.subjectToCuration = subjectToCuration;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getTotalDiscs() {
		return totalDiscs;
	}

	public void setTotalDiscs(int totalDiscs) {
		this.totalDiscs = totalDiscs;
	}

	public int getYear() {
		return year;
	}

	public void setYear(int year) {
		this.year = year;
	}

	public String getTitleNorm() {
		return titleNorm;
	}

	public void setTitleNorm(String titleNorm) {
		this.titleNorm = titleNorm;
	}

	public String getArtist() {
		return artist;
	}

	public void setArtist(String artist) {
		this.artist = artist;
	}

	public String getAlbumNorm() {
		return albumNorm;
	}

	public void setAlbumNorm(String albumNorm) {
		this.albumNorm = albumNorm;
	}

	public int getTrack() {
		return track;
	}

	public void setTrack(int track) {
		this.track = track;
	}

	public long getDurationMillis() {
		return durationMillis;
	}

	public void setDurationMillis(long durationMillis) {
		this.durationMillis = durationMillis;
	}

	public String getMatchedId() {
		return matchedId;
	}

	public void setMatchedId(String matchedId) {
		this.matchedId = matchedId;
	}

	public String getAlbumArtUrl() {
		return albumArtUrl;
	}

	public void setAlbumArtUrl(String albumArtUrl) {
		this.albumArtUrl = albumArtUrl;
	}

	public boolean isDeleted() {
		return deleted;
	}

	public void setDeleted(boolean deleted) {
		this.deleted = deleted;
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public String getAlbumMatchedId() {
		return albumMatchedId;
	}

	public void setAlbumMatchedId(String albumMatchedId) {
		this.albumMatchedId = albumMatchedId;
	}

	public long getCreationDate() {
		return creationDate;
	}

	public void setCreationDate(long creationDate) {
		this.creationDate = creationDate;
	}

	public long getPlayCount() {
		return playCount;
	}

	public void setPlayCount(long playCount) {
		this.playCount = playCount;
	}

	public int getBitrate() {
		return bitrate;
	}

	public void setBitrate(int bitrate) {
		this.bitrate = bitrate;
	}

	public int getRating() {
		return rating;
	}

	public void setRating(int rating) {
		this.rating = rating;
	}

	public String getComment() {
		return comment;
	}

	public void setComment(String comment) {
		this.comment = comment;
	}

	public String getStoreId() {
		return storeId;
	}

	public void setStoreId(String storeId) {
		this.storeId = storeId;
	}

	public String toString() {
		if (artist == null || artist.equals("")) {
			return title;
		} else {
			return artist + " - " + title;
		}
	}

	public String getSongInfo() {
		File file = new File("Images/" + getAlbum() + " - " + getArtist()
				+ ".jpg");
		return "<html><body style='background: transparent;'><table><tr><td><img src='"
				+ (file.exists() ? "file:" + file.getAbsolutePath()
						: Song.class.getResource("/images/album_art.jpg")
								.toString())
				+ "'/></td><td><b style='font-size: 16px;'>Bài hát : "
				+ getTitle()
				+ "</b><br/>Trình bày : "
				+ getArtist()
				+ "<br/>Album : "
				+ getAlbum()
				+ "<br/>Thể loại : "
				+ getGenre()
				+ "<br/>Lượt nghe : "
				+ playCount
				+ "<br/>Thời lượng : " + Utils.toDuaration(durationMillis)
				+ "<br/>Bitrate: "
				+ bitrate + " kbps"
				+ "</td></tr></table></body></html>";
	}

	public String getDirectLink(){
		String link = null;
		try {
			link = MusicManager.googleMusicAPI.getSongURL(this);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return link;
	}

	public void saveToFile(String dir) {
		
	}
}
